<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:s="http://jboss.com/products/seam/taglib"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:a="http://richfaces.org/a4j"
    xmlns:rich="http://richfaces.org/rich"
    template="layout/template.xhtml">

<ui:define name="body">

    <h:form id="expense" styleClass="edit">

        <rich:panel>
            <f:facet name="header">#{expenseHome.managed ? 'Edit' : 'Add'} Expense</f:facet>


            <s:decorate id="expensenameField" template="layout/edit.xhtml">
                <ui:define name="label">Expensename</ui:define>
                <h:inputTextarea id="expensename"
                               cols="80"
                               rows="10"
                           disabled="#{expenseHome.managed}"
                           required="true"
                              value="#{expenseHome.instance.expensename}"/>
            </s:decorate>



            <s:decorate id="amountField" template="layout/edit.xhtml">
                <ui:define name="label">Amount</ui:define>
                <h:inputText id="amount"
                       required="true"
                          value="#{expenseHome.instance.amount}"
                           size="26">
                    <a:support event="onblur" reRender="amountField" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>


            <s:decorate id="expensecategoryField" template="layout/edit.xhtml">
                <ui:define name="label">Expensecategory</ui:define>
                <h:inputTextarea id="expensecategory"
                               cols="80"
                               rows="10"
                              value="#{expenseHome.instance.expensecategory}"/>
            </s:decorate>

            <div style="clear:both">
                <span class="required">*</span>
                required fields
            </div>

        </rich:panel>

        <div class="actionButtons">

            <h:commandButton id="save"
                          value="Save"
                         action="#{expenseHome.persist}"
                       disabled="#{!expenseHome.wired}"
                       rendered="#{!expenseHome.managed}"/>

            <h:commandButton id="update"
                          value="Save"
                         action="#{expenseHome.update}"
                       rendered="#{expenseHome.managed}"/>

            <h:commandButton id="delete"
                          value="Delete"
                         action="#{expenseHome.remove}"
                      immediate="true"
                       rendered="#{expenseHome.managed}"/>

            <s:button id="cancelEdit"
                   value="Cancel"
             propagation="end"
                    view="/Expense.xhtml"
                rendered="#{expenseHome.managed}"/>

            <s:button id="cancelAdd"
                   value="Cancel"
             propagation="end"
                    view="/#{empty expenseFrom ? 'ExpenseList' : expenseFrom}.xhtml"
                rendered="#{!expenseHome.managed}"/>

        </div>
    </h:form>

<rich:tabPanel switchType="ajax">

    <rich:tab label="Accountuser *" labelClass="required">
    <div class="association" id="accountuserParent">

        <h:outputText value="There is no accountuser associated with this expense."
                   rendered="#{expenseHome.instance.accountuser == null}"/>

        <rich:dataTable var="_accountuser"
                   value="#{expenseHome.instance.accountuser}"
                rendered="#{expenseHome.instance.accountuser != null}"
              rowClasses="rvgRowOne,rvgRowTwo"
                      id="accountuserTable">
            <h:column>
                <f:facet name="header">Username</f:facet>
                <h:outputText value="#{_accountuser.username}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Firstname</f:facet>
                <h:outputText value="#{_accountuser.firstname}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Lastname</f:facet>
                <h:outputText value="#{_accountuser.lastname}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Userpassword</f:facet>
                <h:outputText value="#{_accountuser.userpassword}"/>
            </h:column>
        </rich:dataTable>

        <div class="actionButtons">
            <s:button id="#{expenseHome.instance.accountuser != null ? 'changeParent' : 'selectParent'}" value="#{expenseHome.instance.accountuser != null ? 'Change' : 'Select'} accountuser"
                       view="/AccountuserList.xhtml">
                <f:param name="from" value="ExpenseEdit"/>
            </s:button>
        </div>

    </div>
    </rich:tab>
</rich:tabPanel>
</ui:define>

</ui:composition>
